package cn.swh.guguanjia.service.impl;

import cn.swh.guguanjia.entity.SysOffice;
import cn.swh.guguanjia.mapper.SysOfficeMapper;
import cn.swh.guguanjia.service.SysOfficeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
@Transactional
public class SysOfficeServicelmpl extends BaseServicelmpl<SysOffice, Long> implements SysOfficeService {

    @Autowired
    SysOfficeMapper mapper;

    @Override
    @Cacheable(cacheNames = "sysOfficeCache", key = "'com.swh.guguanjia.service.impl.SysofficeServicelmpl:select:'+#sysOffice")
    public List<SysOffice> select(SysOffice sysOffice) {
        return super.select(sysOffice);
    }

    @Override
    public List<SysOffice> selectById(long rid) {
        return mapper.selectById(rid);
    }

    @Override
    public PageInfo<SysOffice> selectPage(int pageNum, int pageSize, Map<String, Object> map) {
        PageHelper.startPage(pageNum,pageSize);
        List<SysOffice> sysOffices = mapper.selectPage(map);
        PageInfo<SysOffice> pageInfo = new PageInfo<>(sysOffices);
        return pageInfo;
    }
}
